<template>
  <view v-if="order" class="pageBg pdt10 pdb120 box-b">
    <view class="box-b">
      <!-- 应收金额+实收金额   -->
      <view class="bgff pdl30 box-b relative">
        <view class="betweenBox lh26 fs26 pd3230320 box-b bdbd9 bdbli">
          <view class="color22 fs26 mgr10 minw124">应收金额:</view>
          <view class="fs26 red-color">￥{{ order.receivableAccounts || 0 }}</view>
        </view>
        <view class="betweenBox lh26 fs26 pd3230320 box-b bdbd9 bdbli">
          <view class="color22 fs26 mgr10 minw124">实收金额:</view>
          <view class="fs26 red-color">￥{{ order.receivedActualAmount || 0 }}</view>
        </view>
      </view>

      <view class="lh32 fs30 color22 mgt50 mgb20 pd030 box-b">请选择支付方式</view>

      <!--  请选择支付方式  -->
      <view class="bgff pdl30 box-b relative mgb60">
        <view v-if="payModes && payModes.length > 0" class="">
          <view
            v-for="(item, index) in payModes"
            :key="index"
            class="flex-align pd3530350 box-b bdbd9 bdbli"
            @click="changeList(index)"
          >
            <view>
              <server-image
                v-if="modesType == index"
                class="img30"
                name="20240702002.png"
                resize="_r72xp"
              />
              <server-image v-else class="img30 disb" name="20230324011.png" resize="_r72xp" />
            </view>

            <view class="flex-align mgl30">
              <view class="">
                <server-image class="img80 disb" name="logo.png" resize="_r72xp" />
              </view>
              <view class="mgl30">
                <view class="lh26 fs26 color22">
                  {{ item.name }}
                </view>
                <view class="lh22 fz22 color99 mgt20">
                  {{ item.subName }}
                </view>
              </view>
            </view>
          </view>
        </view>
      </view>
    </view>

    <!--  确定支付  -->
    <repair-status
      btnName="确定"
      @toOrder="toOrder">
    </repair-status>

    <!-- 支付密码弹框   -->
    <pay-password-popup
      ref="payPasswordPopup"
      :show="showYue"
      @hide="
        inputCode = '';
        showYue = false;
      "
      @submit="payByWallet"
    />

    <!--  支付确认弹框  -->
    <tips-popup
      classNameMask="bg00006"
      :show="showPop['confirmResults']"
      type="middle"
      :showThemeDelete="true"
      class="middle-box box-b"
      style="position: relative"
      @hide="closeDrawer('confirmResults')"
    >
      <view class="pd805050 box-b">
        <view class="lh42 fs36 color22 fw500 tac">支付确认</view>
        <view class="lh40 fs30 color22 fw500 tac mgt40">请确认支付结果</view>
        <view class="between-box mgt50">
          <view
            class="w250 bgf4 color22 minh80 radius40 fs32 ffpf fw500 flex-box"
            @click="closeDrawer('confirmResults')"
          >
            取消
          </view>
          <view
            class="w250 background-main white minh80 radius40 fs32 ffpf fw500 flex-box"
            @click="paySuccess(order.id, true)"
          >
            确定
          </view>
        </view>
      </view>
    </tips-popup>

    <!-- 查询订单未支付  -->
    <tips-popup
      classNameMask="bg00006"
      :show="showPop['pendding']"
      type="middle"
      :showThemeDelete="true"
      class="middle-box box-b"
      style="position: relative"
      @hide="closeDrawer('pendding')"
    >
      <view class="pd805050 box-b">
        <view class="lh42 fs36 color22 fw500 tac">支付确认</view>
        <view class="lh40 fs30 color22 fw500 tac mgt40">
          尚未查询到支付结果,若您已支付,请耐心等待几分钟。
        </view>
        <view class="between-box mgt50">
          <view
            class="w250 bgf4 color22 minh80 radius40 fs32 ffpf fw500 flex-box"
            @click="cancelToIndex"
          >
            返回首页
          </view>
          <view
            class="w250 background-main white minh80 radius40 fs32 ffpf fw500 flex-box"
            @click="switchPage('/pages/product/repair-report/repair-report', true)"
          >
            查看订单
          </view>
        </view>
      </view>
    </tips-popup>
  </view>
</template>

<script>
import { mapState } from 'vuex';
import { encryptPassword } from '@/common/utils';
import tipsPopup from '@/components/tips-popup';
import PayPasswordPopup from '@/components/pay-password-popup';
import repairStatus from '@/pages/member/components/repair-status';
export default {
  name: 'order', // 结算支付页面
  components: {
    tipsPopup,
    PayPasswordPopup,
    repairStatus,
  },
  data() {
    return {
      order: {},
      showOrder: false,
      againClick: true,
      orderid: '',
      // 默认支付方式
      modesType: 0,
      modesValue: '',
      allowBalance: true,
      // 微信支付信息
      wxMpInfos: {},
      // 弹框
      showPop: {
        confirmResults: false, // 支付状态
        pendding: false, // 再次确认支付状态
      },
      // 余额弹框
      inputCode: '',
      showYue: false,
    };
  },
  computed: {
    ...mapState({
      memberInfo: (state) => state.memberInfo || {},
      systemInfo: (state) => state.systemInfo || {},
    }),
    // 支付方式
    payModes() {
      // 虚拟数据 start
      const systemInfo = {
        alipayShow: true,
        alipayShowBo: true,
        wechatPayShow: true,
        wechatPayShowBo: true,
        cashReceipts: true,
        cashReceiptsBo: true,
        corporateTransfer: true,
        corporateTransferBo: true,
        contractTransfer: true,
        contractTransferBo: true,
        annualAndMonthlyPackage: true,
        annualAndMonthlyPackageBo: true,
        notYetReceivedPay: true,
        notYetReceivedPayBo: true,
      };
      // 虚拟数据 end

      // 全部支付方式
      let {
        alipayShow,
        alipayShowBo,
        wechatPayShow,
        wechatPayShowBo,
        cashReceipts,
        cashReceiptsBo,
        corporateTransfer,
        corporateTransferBo,
        contractTransfer,
        contractTransferBo,
        annualAndMonthlyPackage,
        annualAndMonthlyPackageBo,
        notYetReceivedPay,
        notYetReceivedPayBo,
      } =
        // = this.systemInfo;
        systemInfo;
      const allModes = [
        {
          value: '1',
          name: '支付宝支付',
          subName: '支付宝线下支付收款',
          show: alipayShow,
        },
        {
          value: '2',
          name: '微信支付',
          subName: '微信线下支付收款',
          show: wechatPayShow,
        },
        {
          value: '3',
          name: '现金收款',
          subName: '使用现金进行支付',
          show: cashReceipts,
        },
        {
          value: '4',
          name: '对公转账',
          subName: '使用对公转账进行支付',
          show: corporateTransfer,
        },
        {
          value: '5',
          name: '合同转账',
          subName: '使用合同转账进行支付',
          show: contractTransfer,
        },
        {
          value: '6',
          name: '包年包月',
          subName: '使用包年包月进行支付',
          show: annualAndMonthlyPackage,
        },
        {
          value: '7',
          name: '暂未收款',
          subName: '暂未收款',
          show: notYetReceivedPay,
        },
      ];
      let realModes = [];
      // #ifdef H5
      const h5PayTypeList = ['1', '2', '3', '4', '5', '6', '7'];
      realModes = allModes.filter((v) => h5PayTypeList.includes(v.value) && v.show);
      // #endif

      // #ifdef MP-WEIXIN
      realModes = allModes.filter(
        (v) => ['1', '2', '3', '4', '5', '6', '7'].includes(v.value) && v.show
      );
      // #endif

      // #ifdef APP-PLUS
      realModes = allModes.filter(
        (v) => ['1', '2', '3', '4', '5', '6', '7'].includes(v.value) && v.show
      );
      // #endif

      return realModes;
    },
    appOrderPath() {
      const vm = this;
      const memberSecret = uni.getStorageSync('memberSecretV2');
      const params = {
        orderAmount: vm.order.orderAmount,
        type: vm.order.type,
        createDate: vm.order.createDate,
        id: vm.order.id,
        memberId: vm.order.memberId,
        memberSecret: memberSecret,
        payPollId: vm.wxMpInfos.id || '',
        originalId: vm.wxMpInfos.originalId || '',
        // #ifdef APP-PLUS
        from: 'APP',
        // #endif
      };
      const paramsArr = Object.entries(params);
      let query = '';
      for (const [k, v] of paramsArr) {
        query += `&${k}=${v}`;
      }
      return `/pages/order/order?${query.substring(1)}`;
    },
  },
  onLoad(e) {
    // if(e&&e.order){
    //   this.order = JSON.parse(e.order)
    // }
    if (e && e.orderid) {
      this.orderid = e.orderid;
      this.getList();
    }
  },
  onPullDownRefresh() {
    const vm = this;
    vm.getList().then(() => {
      uni.stopPullDownRefresh();
    });
  },
  methods: {
    getList(againClick = false) {
      const vm = this;
      uni.showLoading({
        title: 'loading...',
      });

      // 虚拟数据 start
      let data = {
        id: 1,
        // 支付状态
        payStatus: 1,
        memberId: 11111,
        orderAmount: 700,
        type: 'h5pay',
        receivableAccounts: 700,
        receivedActualAmount: 700,
        submittime: 1604029871000,
      };

      data.submittime = data.submittime ? vm.dateFormatFun(data.submittime, 'YYYY-MM-DD') : '';
      vm.order = data;
      if (againClick) {
        vm.againClick = true;
      }
      uni.hideLoading();
      return new Promise(function (resolve) {
        resolve();
      });
      // 虚拟数据 end

      let param = {
        orderid: vm.orderid,
      };
      return new Promise(function (resolve) {
        vm.apiUrl
          .listOfBranches({
            data: param,
          })
          .then((res) => {
            const { code, data = {} } = res.data;
            if (code == 0) {
              data.submittime = data.submittime ? vm.dateFormatFun(data.submittime, 'YYYY-MM-DD') : '';
              vm.order = data;
            }
          });
        resolve();
      }).finally(() => {
        if (againClick) {
          vm.againClick = true;
        }
        uni.hideLoading();
        if (vm.order && vm.order.length > 0) {
          vm.showOrder = false;
        } else {
          vm.showOrder = true;
        }
      });
    },
    // 支付方式 start
    changeList(index) {
      const vm = this;
      if (vm.modesType == index) return;
      if (!vm.againClick) return;
      vm.againClick = false;
      vm.modesType = index;
      vm.modesValue = vm.payModes[vm.modesType].value;
      vm.againClick = true;
    },
    setModesValue() {
      const vm = this;
      if (!vm.modesValue) {
        vm.modesValue = vm.payModes[vm.modesType].value;
      }
    },
    // 支付宝支付 start
    payByAlipay_v3() {
      const vm = this;

      // #ifdef H5
      this.aggregatePay_v3({ type: 'h5pay', assignPayType: 'alipay-MWEB' }).then(
        ({ url, versions }) => {
          console.log('url, versions', url, versions);
          if (url && ['V1', 'V2', 'V3', 'V5', 'V6'].includes(versions)) {
            window.location.href = url;
          }
        }
      );
      // #endif

      // #ifdef APP-PLUS
      vm.payByAlipay_v3_thirdparty();
      // #endif
    },
    aggregatePay_v3(o) {
      const vm = this;
      // 虚拟数据 start
      if (!vm.allowBalance) return;
      if (o.type == 'h5pay') {
        const returnUrl = window ? window.location.href : '';
        o.return_url = '';
        if (returnUrl) o.return_url = `${returnUrl}${/\?/.test(returnUrl) ? '&' : '?'}isH5pay=true`;
      }
      uni.showLoading({
        title: '加载中...',
        mask: true,
      });
      vm.allowBalance = false; // 防误触

      vm.allowBalance = true;
      let appPayRequest = 'https://www.baidu.com/?tn=48021271_68_hao_pg';
      let versions = 'V1';
      let obj = {
        url: appPayRequest,
        versions,
      };
      uni.hideLoading();
      return new Promise(function (resolve) {
        resolve(obj);
      });
      // 虚拟数据 end

      if (!vm.allowBalance) return;
      if (o.type == 'h5pay') {
        const returnUrl = window ? window.location.href : '';
        o.return_url = '';
        if (returnUrl) o.return_url = `${returnUrl}${/\?/.test(returnUrl) ? '&' : '?'}isH5pay=true`;
      }
      uni.showLoading({
        title: '加载中...',
        mask: true,
      });
      vm.allowBalance = false; // 防误触
      return this.apiUrl
        .payByCloud({
          data: {
            orderId: vm.order.id,
            memberId: vm.order.memberId,
            ...o,
          },
        })
        .then((res) => {
          const {
            code,
            msg:message='',
            data: { outTradeNo = '', appPayRequest = undefined, versions = '' },
          } = res.data;
          if (code == 0) {
            if (o.type == 'fastPay') {
              return {
                outTradeNo: outTradeNo,
              };
            }
            if (!appPayRequest) return Promise.reject('发生未知错误，请联系客服：【无效data】');
            return {
              url: appPayRequest,
              versions,
            };
          }
          return Promise.reject(message);
        })
        .catch((err) => {
          if (err != undefined) {
            uni.showToast({
              title: err,
              mask: false,
              icon: 'none',
              duration: 1500,
            });
          } else {
            uni.showToast({
              title: '系统繁忙',
              mask: false,
              icon: 'none',
              duration: 1500,
            });
          }
        })
        .finally(() => {
          uni.hideLoading();
          this.allowBalance = true;
        });
    },
    payByAlipay_v3_thirdparty() {
      const vm = this;

      // 虚拟数据 start
      if (!vm.againClick) return;
      vm.againClick = false; // 防误触
      uni.showLoading({
        title: '加载中...',
        mask: true,
      });
      switch (vm.$platform) {
        case 'android':
          vm.openAlipay(`alipays://platformapi/startapp?saId=10000007&qrcode='' : ''}`);
          break;
        case 'ios':
          vm.openAlipay(`alipay://platformapi/startapp?saId=10000007&qrcode='' : ''}`);
          break;
        default:
          break;
      }
      uni.hideLoading();
      vm.againClick = true;
      // 虚拟数据 end

      if (!vm.againClick) return;
      vm.againClick = false; // 防误触
      uni.showLoading({
        title: '加载中...',
        mask: true,
      });
      vm.apiUrl
        .payByAlipay_v3_thirdparty({
          data: {
            orderId: vm.order.id,
            type: 'ali_app',
          },
        })
        .then((res) => {
          uni.hideLoading();
          vm.againClick = true;
          const {
            code,
            msg:message='',
            data: { appPayRequest = undefined },
          } = res.data;
          if (code == 0) {
            if (appPayRequest == undefined) {
              uni.showToast({
                title: '发生未知错误，请联系客服：【无效data】',
                mask: false,
                icon: 'none',
                duration: 1500,
              });
              return;
            }
            switch (vm.$platform) {
              case 'android':
                vm.openAlipay(
                  `alipays://platformapi/startapp?saId=10000007&qrcode=${
                    appPayRequest.qrCode ? appPayRequest.qrCode : ''
                  }`
                );
                break;
              case 'ios':
                vm.openAlipay(
                  `alipay://platformapi/startapp?saId=10000007&qrcode=${
                    appPayRequest.qrCode ? appPayRequest.qrCode : ''
                  }`
                );
                break;
              default:
                break;
            }
          } else if (message != undefined) {
            uni.showToast({
              title: message,
              mask: false,
              icon: 'none',
              duration: 1500,
            });
          } else {
            uni.showToast({
              title: '系统繁忙',
              mask: false,
              icon: 'none',
              duration: 1500,
            });
          }
        });
    },
    // 调起支付宝支付
    openAlipay(types) {
      // console.log('调起支付宝支付,openAlipay', types)
      plus.runtime.openURL(types, () => {
        uni.showToast({
          title: '请确认已安装支付宝',
          mask: false,
          icon: 'none',
          duration: 1500,
        });
      });
    },
    // 支付宝支付 end
    // 微信支付 start
    payByWechat_v3() {
      const vm = this;

      // 虚拟数据 start
      let origin = location.origin;
      let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc1775185269f4da5&redirect_uri=${origin}/%23/pages/order/order&response_type=code&scope=snsapi_base#wechat_redirect`;
      location.href = url;
      return;
      // 虚拟数据 end

      // #ifdef H5
      this.getWxPayPoll_v3().then((res) => {
        const { code, data: rData, message } = res.data;
        if (code != 200) {
          this.showMessage({ tile: message });
          return;
        }
        this.wxMpInfos = rData;
        this.payByWechat_v3_H5();
      });
      // #endif

      // #ifdef MP-WEIXIN
      this.payByWechat_v3_WeChatMp();
      // #endif

      // #ifdef APP-PLUS
      // this.aggregatePay_v3({type: 'wx_native'}).then(url => {
      //   if (url) this.doAggregatePay_v3('WXPAY', url)
      // })
      if (this.systemInfo.wxVersion == '365mp') {
        this.getWxPayPoll_v3().then((res) => {
          const { code, data: rData, message } = res.data;
          if (code != 200) {
            this.showMessage({ tile: message });
            return;
          }
          this.wxMpInfos = rData;
          this.openWxMini();
        });
      } else {
        this.aggregatePay_v3({ type: 'wx_native' }).then(({ url }) => {
          if (url) this.doAggregatePay_v3('WXPAY', url);
        });
      }
      // #endif
    },
    getWxPayPoll_v3() {
      const vm = this;
      const { id, memberId } = this.order;
      const params = {
        id: id,
        memberId: memberId,
      };
      return vm.apiUrl.getWxPayPoll({ data: params });
    },
    payByWechat_v3_H5() {
      const vm = this;
      if (!this.allowBalance) return;
      uni.showLoading({
        title: '加载中...',
        mask: true,
      });
      vm.allowBalance = false;
      const arr = vm.appOrderPath.split('?');
      const params = {
        path: arr[0],
        query: arr[1].replace(/&/g, '#'),
        appId: vm.wxMpInfos.projectId,
      };

      vm.apiUrl
        .getWxAppUrlscheme({ data: params })
        .then((res) => {
          const {
            code,
            data: { openlink = '' },
          } = res.data;
          if (code == 0) {
            // eslint-disable-next-line no-restricted-globals
            location.href = openlink;
          }
        })
        .finally(() => {
          uni.hideLoading();
          vm.allowBalance = true;
        });

      // return;
      // // let origin = location.origin;
      // // let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc1775185269f4da5&redirect_uri=${origin}/%23/pages/order/order&response_type=code&scope=snsapi_base#wechat_redirect`;
      // // location.href = url;
    },
    payByWechat_v3_WeChatMp() {
      const vm = this;
      if (!vm.allowBalance) return;
      uni.showLoading({
        title: '加载中...',
        mask: true,
      });
      vm.allowBalance = false;

      const loginPromise = new Promise((resolve, reject) => {
        uni.login({
          provider: 'weixin',
          success: (res) => {
            resolve(res);
          },
          fail: (err) => {
            reject(new Error(err));
          },
        });
      });

      loginPromise
        .then((res) => vm.apiUrl.getOpenId({ data: { code: res.code, appId: 'wechat-pz' } }))
        .then((res) => {
          const {
            code,
            data: { openId = '' },
          } = res.data;
          if (code == 0) {
            const params = {
              openId: openId,
              orderId: vm.order.id,
              type: 'wx_mini',
              memberId: vm.order.memberId,
            };
            return vm.apiUrl.payByCloud({ data: params });
          }
          return Promise.reject(res);
        })
        .then((res) => {
          const {
            code,
            data: { timeStamp = '', nonceStr = '', pkg = '', paySign = '', signType = '' },
          } = res.data;
          if (code == 0) {
            return new Promise((resolve, reject) => {
              const rData = res.data.data;
              wx.requestPayment({
                timeStamp: timeStamp,
                nonceStr: nonceStr,
                package: pkg || rData.package,
                paySign: paySign,
                signType: signType,
                success: () => {
                  vm.paySuccess(vm.order.id);
                  resolve();
                },
                fail(err) {
                  reject(new Error(err));
                },
              });
            });
          }
          return Promise.reject(res);
        })
        .catch(() => {
          uni.showToast({
            icon: 'none',
            title: '支付失败，请稍后重试.',
            duration: 2000,
          });
        })
        .finally(() => {
          uni.hideLoading();
          vm.allowBalance = true;
        });
    },
    // 微信支付 end
    // 现金收款 start
    payByBalance_v3() {
      if (this.inputCode == '') {
        this.showYue = !this.showYue;
      } else {
        this.payByCashReceipts();
      }
    },
    payByCashReceipts(psw) {
      const vm = this;

      // 虚拟数据 start
      if (!vm.allowBalance) return;
      if (psw) vm.inputCode = psw;
      uni.showLoading({
        title: 'loading...',
      });
      vm.allowBalance = false; // 防误触

      vm.showYueHide();
      uni.hideLoading();
      vm.allowBalance = true;
      vm.paySuccess(vm.order.id);
      return;
      // 虚拟数据 end

      if (!vm.allowBalance) return;
      if (psw) vm.inputCode = psw;
      uni.showLoading({
        title: 'loading...',
      });
      vm.allowBalance = false; // 防误触
      this.apiUrl
        .payByCashReceipts({
          data: {
            orderId: vm.order.id,
            password: encryptPassword(vm.inputCode),
          },
        })
        .then((res) => {
          vm.showYueHide();
          uni.hideLoading();
          vm.allowBalance = true;
          const { code,msg:message='' } = res.data;
          if (code == 0) {
            vm.paySuccess(vm.order.id);
          } else {
            uni.showToast({
              title: message,
              mask: false,
              icon: 'none',
              duration: 1500,
            });
          }
        });
    },
    // 现金收款 end
    // 密码弹框
    showYueHide() {
      const vm = this;
      vm.showYue = false;
      vm.inputCode = '';
    },
    payByWallet(psw) {
      const vm = this;
      vm.setModesValue();
      switch (vm.modesValue) {
        case '3':
          vm.payByCashReceipts(psw);
          break;
        // case '4':
        //   vm.payByCashReceipts(psw);
        //   break;
        default:
          break;
      }
    },
    // 支付成功
    paySuccess(id, againClick = false) {
      this.savePayingProductType().then(() => {
        if (this.order.payStatus == 1) {
          uni.redirectTo({
            url: `/pages/order/pay-success/pay-success?id=${id}`,
          });
        } else {
          if (!againClick) {
            this.showPop['confirmResults'] = true;
          } else {
            this.showPop['pendding'] = true;
          }
        }
      });
    },
    savePayingProductType() {
      const vm = this;
      return new Promise((resolve) => {
        vm.apiUrl
          .getOrderDetail({
            data: {
              orderId: vm.order.id,
            },
          })
          .then((res) => {
            const { code, data } = res.data;
            if (code == 0) {
              if (data) {
                vm.order = {
                  ...vm.order,
                  ...data,
                };
                resolve();
              }
            }
          });
      });
    },
    // 多ifelse优化
    changeType(index, name = '') {
      const vm = this;
      let isReturn = false;
      return new Promise(function (resolve) {
        const branches = [
          {
            condition: '1',
            code: () => {
              vm.payByAlipay_v3();
            },
          },
          {
            condition: '2',
            code: () => {
              vm.payByWechat_v3();
            },
          },
          {
            condition: '3',
            code: () => {
              vm.payByBalance_v3();
            },
          },
          {
            condition: '4',
            code: () => {},
          },
          {
            condition: '5',
            code: () => {},
          },
          {
            condition: '6',
            code: () => {},
          },
          {
            condition: '7',
            code: () => {},
          },
        ];
        const execute = (branch) => branch.code();
        const applicableBranches = branches.filter((branch) => branch.condition == name);
        applicableBranches.forEach(execute);

        resolve(isReturn);
      });
    },
    toOrder() {
      const vm = this;
      //记录支付
      vm.submitSettlemenMethod();

      // 实际支付
      // vm.setModesValue()
      // vm.changeType(vm.modesType,vm.modesValue)
    },
    // 支付方式 end
    // 弹框
    showDrawer(name) {
      this.showPop[name] = true;
    },
    closeDrawer(name) {
      this.showPop[name] = false;
    },
    cancelToIndex() {
      const vm = this;
      vm.closeDrawer('confirmResults');
      vm.switchPage('/pages/index/index');
    },
    submitSettlemenMethod() {
      const vm = this;
      if (!vm.againClick) return;
      vm.againClick = false;

      uni.showLoading({
        title: 'loading...',
      });

      // 虚拟数据 start
      uni.hideLoading();
      this.showMessage({ title: '提交成功', icon: 'success', duration: 1500 }).then(() => {
        vm.againClick = true;
      });
      return new Promise(function (resolve) {
        resolve();
      });
      // 虚拟数据 end

      let param = {
        orderid: vm.orderid,
        modesValue: vm.modesValue,
      };
      return new Promise(function (resolve) {
        vm.apiUrl
          .submitSettlemenMethod({
            data: param,
          })
          .then((res) => {
            uni.hideLoading();
            const { code,msg:message='' } = res.data;
            if (code == 0) {
              this.showMessage({ title: '提交成功', icon: 'success' }).then(() => {});
            } else {
              vm.showMessage({ title: message });
            }
          });
        resolve();
      }).finally(() => {
        vm.sleep(1500).then(() => {
          vm.againClick = true;
        });
      });
    },
  },
};
</script>

<style lang="less" scoped></style>
